LATEX = pdflatex
#LATEX = latex

TARGET=presentation

TEXSRC   = 			\
	presentation.tex 	\
	intro.tex  		\
	design.tex     	 	\
	status.tex		\
	conclusions.tex		
	


EPSIMGS	=  figs/design.eps \
           figs/cert_req.eps \
           figs/transfer.eps



PDFTARGET=$(TARGET).pdf

default: $(PDFTARGET)

PDFIMGS = $(EPSIMGS:.eps=.pdf)

clean:
	rm -f $(TARGET).log $(TEXSRC:.tex=.aux)
	rm -f $(TARGET).lof $(TARGET).lot $(TARGET).toc
	rm -f $(TARGET).bbl $(TARGET).blg $(TARGET).out
	rm -f $(TARGET).dvi $(TARGET).ps $(TARGET).pdf $(PDFIMGS)
	rm -f $(TARGET).nav $(TARGET).snm


$(TARGET).dvi: $(TEXSRC)
	@echo
	@echo \*
	@echo \* Compiling $(TARGET)
	@echo \*
	$(MAKE) $(TARGET).bbl 
	latex $(TARGET)
	@while ( grep "Rerun to get cross-references" $(TARGET).log >/dev/null ); do \
		echo '** Re-running LaTeX **'; \
		latex $(TARGET); \
	done

$(TARGET).ps: $(TARGET).dvi 
	@echo
	@echo \*
	@echo \* Converting $< to PostScript
	@echo \*
	dvips -t letterSize -o $@ $<

# use pdfLaTex to generate pdf, since
# the pdf will contain bookmarks and hyperlinks.
$(TARGET).pdf: $(TEXSRC) $(PDFIMGS)
	@echo
	@echo \*
	@echo \* Running pdfLaTeX $(TARGET)
	@echo \*
	pdflatex $(TARGET).tex
	pdflatex $(TARGET).tex
	@while ( grep "Rerun to get cross-references" $(TARGET).log >/dev/null ); do \
		echo '** Re-running pdfLaTeX **'; \
		pdflatex $(TARGET).tex; \
	done

# convert eps files to pdf for pdfLaTeX
%.pdf: %.eps
	egrep -v "^%%Orientation:" $< | epstopdf --filter --outfile=$@



# run bibtex
$(TARGET).bbl: $(TEXSRC) 
	latex $(TARGET).tex

